{% extends "base_generic.html" %}

{% block title %}{{ author.name }} - 本地图书馆{% endblock %}

{% block content %}
<div class="card">
    <div class="card-header text-white" style="background-color: #ffb3eb;">
        <h1 class="h3 mb-0">作者：{{ author.name }}</h1>
    </div>
    <div class="card-body">
        <div class="row">
            <div class="col-md-8">
                <p class="card-text mt-4">
                    <strong>简介：</strong><br>
                    {{ author.bio }}
                </p>

                {% if author.date_of_birth %}
                <p class="card-text">
                    <strong>出生日期：</strong> {{ author.date_of_birth }}
                </p>
                {% endif %}

                {% if author.date_of_death %}
                <p class="card-text">
                    <strong>去世日期：</strong> {{ author.date_of_death }}
                </p>
                {% endif %}
            </div>

            <div class="col-md-4">
                <div class="card">
                    <div class="card-header text-white" style="background-color: #e0b3ff;">
                        <h5 class="card-title mb-0">
                            <i class="fas fa-book me-2"></i>代表作品
                        </h5>
                    </div>
                    <div class="card-body">
                        <ul class="list-group list-group-flush">
                        {% for book in author.book_set.all %}
                            <li class="list-group-item">
                                <a href="{{ book.get_absolute_url }}" class="text-decoration-none">
                                    {{ book.title }}
                                </a>
                            </li>
                        {% empty %}
                            <li class="list-group-item text-muted">暂无作品信息</li>
                        {% endfor %}
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{% if user.is_authenticated %}
<div class="mt-4">
    <a href="{% url 'author-update' author.pk %}" class="btn btn-outline-secondary me-2">
        <i class="fas fa-edit me-2"></i>更新
    </a>
    <a href="{% url 'author-delete' author.pk %}" class="btn btn-outline-danger">
        <i class="fas fa-trash me-2"></i>删除
    </a>
</div>
{% endif %}

<div class="card mt-3">
    <a href="{% url 'author-list' %}" class="btn btn-link">
        <i class="fas fa-arrow-left me-1"></i>返回作者列表
    </a>
</div>
{% endblock %}